#include "Cache.hpp"
#include "CacheManager.hpp"
#include "Thread.hpp"

#include <iostream>
#include <unistd.h>
#include <memory>
#include <vector>
#include <functional>
using std::vector;
using std::unique_ptr;
using std::function;
using std::endl;
using std::bind;
using std::cout;

void test0(){

    unique_ptr<ylw::Thread> initialThread(new ylw::Thread(
                    ylw::CacheManager::initCache));

    initialThread->start();
    /* ylw::CacheManager::initCache(); */
    string key = "Yangliwei1";
    cout << ylw::CacheManager::getCache(0).query(key) << endl;
    string value = "2501";
    ylw::CacheManager::getCache(0).addElement(key, value);
    ::sleep(3);
    ylw::CacheManager::getCache(0).query(key);

    string key1 = "xukunkun1";
    cout << ylw::CacheManager::getCache(1).query(key1) << endl;
    string value1 = "2511";
    ylw::CacheManager::getCache(1).addElement(key1, value1);
    ::sleep(3);
    ylw::CacheManager::getCache(1).query(key1);

    string key2 = "yangshicheng1";
    cout << ylw::CacheManager::getCache(2).query(key2) << endl;
    string value2 = "1234";
    ylw::CacheManager::getCache(2).addElement(key2, value2);
    ::sleep(3);
    ylw::CacheManager::getCache(2).query(key2);

    string key11 = "baoxinyu1";
    cout << ylw::CacheManager::getCache(1).query(key11) << endl;
    string value11 = "2148";
    ylw::CacheManager::getCache(1).addElement(key11, value11);
    ::sleep(3);
    ylw::CacheManager::getCache(1).query(key11);
    /* string filename = "result.txt"; */
    /* cache.writeToFile(filename); */
}

int main(){
    test0();
}
